package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAgentMessage;
import com.ruoyi.zsyh.service.IZsyhAgentMessageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大区会长消息提醒Controller
 * 
 * @author yuexl
 * @date 2022-01-20
 */
@Controller
@RequestMapping("/zsyh/message")
public class ZsyhAgentMessageController extends BaseController
{
    private String prefix = "zsyh/message";

    @Autowired
    private IZsyhAgentMessageService zsyhAgentMessageService;

    @RequiresPermissions("zsyh:message:view")
    @GetMapping()
    public String message()
    {
        return prefix + "/message";
    }

    /**
     * 查询大区会长消息提醒列表
     */
    @RequiresPermissions("zsyh:message:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAgentMessage zsyhAgentMessage)
    {
        startPage();
        List<ZsyhAgentMessage> list = zsyhAgentMessageService.selectZsyhAgentMessageList(zsyhAgentMessage);
        return getDataTable(list);
    }

    /**
     * 导出大区会长消息提醒列表
     */
    @RequiresPermissions("zsyh:message:export")
    @Log(title = "大区会长消息提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAgentMessage zsyhAgentMessage)
    {
        List<ZsyhAgentMessage> list = zsyhAgentMessageService.selectZsyhAgentMessageList(zsyhAgentMessage);
        ExcelUtil<ZsyhAgentMessage> util = new ExcelUtil<ZsyhAgentMessage>(ZsyhAgentMessage.class);
        return util.exportExcel(list, "大区会长消息提醒数据");
    }

    /**
     * 新增大区会长消息提醒
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存大区会长消息提醒
     */
    @RequiresPermissions("zsyh:message:add")
    @Log(title = "大区会长消息提醒", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAgentMessage zsyhAgentMessage)
    {
        return toAjax(zsyhAgentMessageService.insertZsyhAgentMessage(zsyhAgentMessage));
    }

    /**
     * 修改大区会长消息提醒
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAgentMessage zsyhAgentMessage = zsyhAgentMessageService.selectZsyhAgentMessageById(id);
        mmap.put("zsyhAgentMessage", zsyhAgentMessage);
        return prefix + "/edit";
    }

    /**
     * 修改保存大区会长消息提醒
     */
    @RequiresPermissions("zsyh:message:edit")
    @Log(title = "大区会长消息提醒", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAgentMessage zsyhAgentMessage)
    {
        return toAjax(zsyhAgentMessageService.updateZsyhAgentMessage(zsyhAgentMessage));
    }

    /**
     * 删除大区会长消息提醒
     */
    @RequiresPermissions("zsyh:message:remove")
    @Log(title = "大区会长消息提醒", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAgentMessageService.deleteZsyhAgentMessageByIds(ids));
    }
}
